#pragma once

interface IView;

class CMainView : public CScrollView
{
public:
	CMainView(){}
	virtual ~CMainView(){}

	CDocument* GetDocument() const;
	IView* GetView() const;
	virtual void OnPrepareDC(CDC* pDC, CPrintInfo* pInfo = NULL);
	virtual void OnDraw(CDC* pDC);  
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:
	virtual void OnInitialUpdate();
	virtual BOOL PreTranslateMessage(MSG* pMsg);
	virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
	virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
	virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
	virtual void OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView);

	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
	afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
	afx_msg void OnFilePrintPreview();
	afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);

	DECLARE_DYNCREATE(CMainView)
	DECLARE_MESSAGE_MAP()

private:
	void OnScrolling(const Size& size);
	void OnCanvasRefreshing(const Rect& boundbox,bool whole);
	sys::ObjectPtr m_view;
	CSize m_scrollsize;
};

#ifndef _DEBUG  
inline CDocument* CMainView::GetDocument() const
   { return reinterpret_cast<CDocument*>(m_pDocument); }
#endif

#ifdef _DEBUG
inline void CMainView::AssertValid() const
{
	CScrollView::AssertValid();
}

inline void CMainView::Dump(CDumpContext& dc) const
{
	CScrollView::Dump(dc);
}

inline CDocument* CMainView::GetDocument() const // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDocument)));
	return (CDocument*)m_pDocument;
}
#endif 